<template>
  <div class="row justify-content-center">
    <div class="col-8">
      <form name="editForm" role="form" novalidate v-on:submit.prevent="save()">
        <h2
          id="jhipsterserverApp.contentInfo.home.createOrEditLabel"
          data-cy="ContentInfoCreateUpdateHeading"
          v-text="$t('jhipsterserverApp.contentInfo.home.createOrEditLabel')"
        >
          Create or edit a ContentInfo
        </h2>
        <div>
          <div class="form-group" v-if="contentInfo.id">
            <label for="id" v-text="$t('global.field.id')">ID</label>
            <input type="text" class="form-control" id="id" name="id" v-model="contentInfo.id" readonly />
          </div>
          <div class="form-group">
            <label class="form-control-label" v-text="$t('jhipsterserverApp.contentInfo.contentAuthor')" for="content-info-contentAuthor"
              >Content Author</label
            >
            <input
              type="text"
              class="form-control"
              name="contentAuthor"
              id="content-info-contentAuthor"
              data-cy="contentAuthor"
              :class="{ valid: !$v.contentInfo.contentAuthor.$invalid, invalid: $v.contentInfo.contentAuthor.$invalid }"
              v-model="$v.contentInfo.contentAuthor.$model"
            />
          </div>
          <div class="form-group">
            <label class="form-control-label" v-text="$t('jhipsterserverApp.contentInfo.contentText')" for="content-info-contentText"
              >Content Text</label
            >
            <input
              type="text"
              class="form-control"
              name="contentText"
              id="content-info-contentText"
              data-cy="contentText"
              :class="{ valid: !$v.contentInfo.contentText.$invalid, invalid: $v.contentInfo.contentText.$invalid }"
              v-model="$v.contentInfo.contentText.$model"
            />
          </div>
          <div class="form-group">
            <label class="form-control-label" v-text="$t('jhipsterserverApp.contentInfo.contentImg')" for="content-info-contentImg"
              >Content Img</label
            >
            <input
              type="text"
              class="form-control"
              name="contentImg"
              id="content-info-contentImg"
              data-cy="contentImg"
              :class="{ valid: !$v.contentInfo.contentImg.$invalid, invalid: $v.contentInfo.contentImg.$invalid }"
              v-model="$v.contentInfo.contentImg.$model"
            />
          </div>
          <div class="form-group">
            <label class="form-control-label" v-text="$t('jhipsterserverApp.contentInfo.contentTime')" for="content-info-contentTime"
              >Content Time</label
            >
            <div class="d-flex">
              <input
                id="content-info-contentTime"
                data-cy="contentTime"
                type="datetime-local"
                class="form-control"
                name="contentTime"
                :class="{ valid: !$v.contentInfo.contentTime.$invalid, invalid: $v.contentInfo.contentTime.$invalid }"
                :value="convertDateTimeFromServer($v.contentInfo.contentTime.$model)"
                @change="updateZonedDateTimeField('contentTime', $event)"
              />
            </div>
          </div>
          <div class="form-group">
            <label
              class="form-control-label"
              v-text="$t('jhipsterserverApp.contentInfo.contentPraiseCount')"
              for="content-info-contentPraiseCount"
              >Content Praise Count</label
            >
            <input
              type="number"
              class="form-control"
              name="contentPraiseCount"
              id="content-info-contentPraiseCount"
              data-cy="contentPraiseCount"
              :class="{ valid: !$v.contentInfo.contentPraiseCount.$invalid, invalid: $v.contentInfo.contentPraiseCount.$invalid }"
              v-model.number="$v.contentInfo.contentPraiseCount.$model"
            />
          </div>
          <div class="form-group">
            <label
              class="form-control-label"
              v-text="$t('jhipsterserverApp.contentInfo.contentFavorateCount')"
              for="content-info-contentFavorateCount"
              >Content Favorate Count</label
            >
            <input
              type="number"
              class="form-control"
              name="contentFavorateCount"
              id="content-info-contentFavorateCount"
              data-cy="contentFavorateCount"
              :class="{ valid: !$v.contentInfo.contentFavorateCount.$invalid, invalid: $v.contentInfo.contentFavorateCount.$invalid }"
              v-model.number="$v.contentInfo.contentFavorateCount.$model"
            />
          </div>
          <div class="form-group">
            <label
              class="form-control-label"
              v-text="$t('jhipsterserverApp.contentInfo.contentImgLabel')"
              for="content-info-contentImgLabel"
              >Content Img Label</label
            >
            <input
              type="text"
              class="form-control"
              name="contentImgLabel"
              id="content-info-contentImgLabel"
              data-cy="contentImgLabel"
              :class="{ valid: !$v.contentInfo.contentImgLabel.$invalid, invalid: $v.contentInfo.contentImgLabel.$invalid }"
              v-model="$v.contentInfo.contentImgLabel.$model"
            />
          </div>
          <div class="form-group">
            <label class="form-control-label" v-text="$t('jhipsterserverApp.contentInfo.account')" for="content-info-account"
              >Account</label
            >
            <select class="form-control" id="content-info-account" data-cy="account" name="account" v-model="contentInfo.account">
              <option v-bind:value="null"></option>
              <option
                v-bind:value="
                  contentInfo.account && userAccountOption.id === contentInfo.account.id ? contentInfo.account : userAccountOption
                "
                v-for="userAccountOption in userAccounts"
                :key="userAccountOption.id"
              >
                {{ userAccountOption.id }}
              </option>
            </select>
          </div>
          <div class="form-group">
            <label class="form-control-label" v-text="$t('jhipsterserverApp.contentInfo.contentType')" for="content-info-contentType"
              >Content Type</label
            >
            <select
              class="form-control"
              id="content-info-contentType"
              data-cy="contentType"
              name="contentType"
              v-model="contentInfo.contentType"
            >
              <option v-bind:value="null"></option>
              <option
                v-bind:value="
                  contentInfo.contentType && contentTypeOption.id === contentInfo.contentType.id
                    ? contentInfo.contentType
                    : contentTypeOption
                "
                v-for="contentTypeOption in contentTypes"
                :key="contentTypeOption.id"
              >
                {{ contentTypeOption.id }}
              </option>
            </select>
          </div>
        </div>
        <div>
          <button type="button" id="cancel-save" class="btn btn-secondary" v-on:click="previousState()">
            <font-awesome-icon icon="ban"></font-awesome-icon>&nbsp;<span v-text="$t('entity.action.cancel')">Cancel</span>
          </button>
          <button
            type="submit"
            id="save-entity"
            data-cy="entityCreateSaveButton"
            :disabled="$v.contentInfo.$invalid || isSaving"
            class="btn btn-primary"
          >
            <font-awesome-icon icon="save"></font-awesome-icon>&nbsp;<span v-text="$t('entity.action.save')">Save</span>
          </button>
        </div>
      </form>
    </div>
  </div>
</template>
<script lang="ts" src="./content-info-update.component.ts"></script>
